package ypmits.bitmap.vo {
	
	import ypmits.utils.SimpleMath;

	import flash.display.Sprite;
	import flash.geom.Point;

	/**
	 * @author Dave Lenz
	 */
	public class BitmapPixelDustVO extends Sprite {
		public var particledata : ParticleDataVO;

		public function BitmapPixelDustVO( particledata : ParticleDataVO ) {
			this.particledata = particledata;
			if( particledata.obj ) {
				addChild( particledata.obj );
			}
		}

		
		public function render( mousepoint : Point, radius : Number ) : void {
			var particledatapoint : Point = new Point( particledata.x, particledata.y );
			var dist : Number;
			var deg : Number;
			var angle : Number;
			var circlepoint : Point;
			
			dist = SimpleMath.getDistance( mousepoint, particledatapoint );
				
			if( dist < radius ) {
					
				//points.push( particledata );
				deg = SimpleMath.getAngle( mousepoint, particledatapoint );
				angle = SimpleMath.degreesToRadians( deg - 90 );
				circlepoint = new Point( dist * Math.cos( angle ), dist * Math.sin( angle ) );

				var _x : Number = (circlepoint.x - (particledata.obj.mouseX)) / dist;
				var _y : Number = (circlepoint.y - (particledata.obj.mouseY)) / dist;
				particledata.obj.x = particledata.obj.x + _x;
				particledata.obj.y = particledata.obj.y + _y;
			}
		}
	}
}
